<template>
    <div style="width: 500vw;height: 300vh">
        <el-dialog title="商品基础库" :visible.sync="curShow" @close="doClose">
            <CPageTable :multiSelect="false" :data="tableData" :curPage="paging.curPage" :total="paging.total" @changeSize="changeSize" @changePage="search">
                <template slot-scope="scope">
                    <CBtn type="text" @click="selRow(scope.row)">选择</CBtn>
                </template>
            </CPageTable>
        </el-dialog>
    </div>
    
</template>

<script>
export default {
    data() {
        return {
            curShow: false,
            tableData: {},
            listCondition: [],
            otherCondition: [],
            paging: {
                curPage: 1,
                pageSize: 20,
                total: 0
            },
            templateId: ""
        }
    },
    created() {
        this.templateId = "57f5da29-317e-4e8c-9b0b-7c60fc6b6283";
        this.search(1);
        this.curShow = true;
    },
    methods: {
        doClose() {
            this.curShow = false;
            this.$emit("close", false);
        },
        selRow(row) {
            
            this.$emit("selRow", row);
        },
        changeSize(size) {
            this.paging.pageSize = size;
            this.search(1);
        },
        search(page, conditions) {
            if (page) {
                this.paging.curPage = page;
            }
            if (!conditions) {
                conditions = [...this.listCondition, ...this.otherCondition];
            }
            this.$sys.templateQuery({
                paging: this.paging,
                listCondition: conditions,
                templateId: this.templateId
            }).then(res => {
                this.tableData = res.data;
                this.paging.total = res.data.paging.total;
            })
        },
    }
}
</script>

<style lang="scss" scoped>
</style>